#import "TTTableHelpItem.h"


///////////////////////////////////////////////////////////////////////////////////////////////////  

////////////////////////////////////////////////////////
//////   INTableCaptionedItemWithThreeImagesBelow  /////  
////////////////////////////////////////////////////////

@implementation TTTableHelpItem

@synthesize caption = _caption, timestamp = _timestamp, imageURL = _imageURL;

///////////////////////////////////////////////////////////////////////////////////////////////////
// class public

+ (id)itemWithText:(TTStyledText*)text 
	   displayname:(NSString*)displayname
		 timestamp:(NSDate*)timestamp
		pictureurl:(NSString*)pictureurl 
			   URL:(NSString*)url 
{
		TTTableHelpItem* item = [[[self alloc] init] autorelease];
		item.text = text;
		item.caption = displayname;
		item.imageURL = pictureurl;
		item.URL = url;
		item.timestamp = timestamp;
		return item;
	}

	
///////////////////////////////////////////////////////////////////////////////////////////////////
// NSObject

- (id)init {
	if (self = [super init]) {
		_caption = nil;
		_timestamp = nil;
		_imageURL = nil;
//		_imageStyle = nil;
	}
	return self;
}

- (void)dealloc {
	TT_RELEASE_SAFELY(_caption);
	TT_RELEASE_SAFELY(_timestamp);
	TT_RELEASE_SAFELY(_imageURL);
//	TT_RELEASE_SAFELY(_imageStyle);
	[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// NSCoding

- (id)initWithCoder:(NSCoder*)decoder {
	if (self = [super initWithCoder:decoder]) {
		self.caption = [decoder decodeObjectForKey:@"caption"];
		self.timestamp = [decoder decodeObjectForKey:@"timestamp"];
		self.imageURL = [decoder decodeObjectForKey:@"imageURL"];
	}
	return self;
}

- (void)encodeWithCoder:(NSCoder*)encoder {
	[super encodeWithCoder:encoder];
	if (self.caption) {
		[encoder encodeObject:self.caption forKey:@"caption"];
	}
	if (self.timestamp) {
		[encoder encodeObject:self.timestamp forKey:@"timestamp"];
	}
	if (self.imageURL) {
		[encoder encodeObject:self.imageURL forKey:@"imageURL"];
	}
}

@end
